-
Notifications
You must be signed in to change notification settings - Fork 267
update: details on Navigation 3 implementation available in CMP 1.10 #591
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
|
||
| ```text | ||
| [versions] | ||
| compose-multiplatform-navigation3 = "1.0.0-alpha05" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would name it just multiplatform-nav3 and multiplatform-nav3-ui
|
|
||
| > While Navigation 3 is released as two artifacts, `navigation3:navigation3-ui` and `navigation3:navigation3-common`, | ||
| > only `navigation-ui` needs a separate Compose Multiplatform implementation. | ||
| > A dependency on `navigation3-common` is added implicitly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added transitively
| ``` | ||
|
|
||
| Finally, you can try out the [proof-of-concept library](https://github.com/terrakok/navigation3-browser) | ||
| authored by a JetBrains engineer that adds support for Navigation 3 to web targets: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the library already supports web targets. my library adds an integration with browser history buttons
ElviraMustafina
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry about the comment overload, got a bit too enthusiastic
| [//]: # (title: Navigation 3 in Compose Multiplatform) | ||
| <primary-label ref="alpha"/> | ||
|
|
||
| [Android's Navigation library](https://developer.android.com/guide/navigation) is upgraded to Navigation 3, a redesigned approach to navigation that works with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| [Android's Navigation library](https://developer.android.com/guide/navigation) is upgraded to Navigation 3, a redesigned approach to navigation that works with | |
| [Android's Navigation library](https://developer.android.com/guide/navigation) has been upgraded to Navigation 3, introducing a redesigned approach to navigation that works with |
|
|
||
| [Android's Navigation library](https://developer.android.com/guide/navigation) is upgraded to Navigation 3, a redesigned approach to navigation that works with | ||
| Compose and takes into account feedback to the previous version of the library. | ||
| Starting with the version 1.10, Compose Multiplatform helps adopt Navigation 3 into multiplatform projects on all supported platforms: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Starting with the version 1.10, Compose Multiplatform helps adopt Navigation 3 into multiplatform projects on all supported platforms: | |
| Starting with version 1.10, Compose Multiplatform simplifies adopting Navigation 3 in multiplatform projects for all supported platforms: |
| ## General overview | ||
|
|
||
| Navigation 3 is more than a new version of the library — in a lot of ways it's a new library entirely. | ||
| To dive deeper into the philosophy behind it, see the [Android Developers blog post](https://android-developers.googleblog.com/2025/05/announcing-jetpack-navigation-3-for-compose.html). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| To dive deeper into the philosophy behind it, see the [Android Developers blog post](https://android-developers.googleblog.com/2025/05/announcing-jetpack-navigation-3-for-compose.html). | |
| To learn more about the philosophy behind this redesign, see the [Android Developers blog post](https://android-developers.googleblog.com/2025/05/announcing-jetpack-navigation-3-for-compose.html). |
| Navigation 3 is more than a new version of the library — in a lot of ways it's a new library entirely. | ||
| To dive deeper into the philosophy behind it, see the [Android Developers blog post](https://android-developers.googleblog.com/2025/05/announcing-jetpack-navigation-3-for-compose.html). | ||
|
|
||
| The major changes in the new library are: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| The major changes in the new library are: | |
| Key changes in Navigation 3 include: |
| The major changes in the new library are: | ||
|
|
||
| * **User-owned back stack**. Instead of operating a single library back stack, | ||
| you create and manage a `SnapshotStateList` of states which is observed by the UI. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about this one (feels like "Big UI is Watching You")
| you create and manage a `SnapshotStateList` of states which is observed by the UI. | |
| you create and manage a `SnapshotStateList` of states, which the UI observes directly. |
| Navigation 3 is closely aligned with Compose and therefore a navigation implementation written for Android works in common | ||
| Compose Multiplatform code almost without changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Navigation 3 is closely aligned with Compose and therefore a navigation implementation written for Android works in common | |
| Compose Multiplatform code almost without changes. | |
| Navigation 3 is closely aligned with Compose, allowing an Android navigation implementation to work in common | |
| Compose Multiplatform code with minimal changes. |
|
|
||
| Navigation 3 is closely aligned with Compose and therefore a navigation implementation written for Android works in common | ||
| Compose Multiplatform code almost without changes. | ||
| The only thing you need to add to support non-JVM platforms like web and iOS is implement |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| The only thing you need to add to support non-JVM platforms like web and iOS is implement | |
| To support non-JVM platforms like web and iOS, the only thing you need is to implement |
| To take this into account, the library has two overloads for the `rememberNavBackStack()` function: | ||
|
|
||
| * [The first overload](https://developer.android.com/reference/kotlin/androidx/navigation3/runtime/package-summary#rememberNavBackStack(kotlin.Array)) | ||
| only takes a set of `NavKey` and requires a reflection-based serializer. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
set of NavKey elements? values?
| also takes a `SavedStateConfiguration` parameter that allows you to provide a `SerializersModule` and handle open polymorphism | ||
| correctly across all platforms. | ||
|
|
||
| In the multiplatform examples of Navigation 3 it can look [like this](https://github.com/terrakok/nav3-recipes/blob/8ff455499877225b638d5fcd82b232834f819422/sharedUI/src/commonMain/kotlin/com/example/nav3recipes/basicdsl/BasicDslActivity.kt#L40): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| In the multiplatform examples of Navigation 3 it can look [like this](https://github.com/terrakok/nav3-recipes/blob/8ff455499877225b638d5fcd82b232834f819422/sharedUI/src/commonMain/kotlin/com/example/nav3recipes/basicdsl/BasicDslActivity.kt#L40): | |
| In the Navigation 3 multiplatform examples, polymorphic serialization can look [like this](https://github.com/terrakok/nav3-recipes/blob/8ff455499877225b638d5fcd82b232834f819422/sharedUI/src/commonMain/kotlin/com/example/nav3recipes/basicdsl/BasicDslActivity.kt#L40): |
| Sometimes this documentation uses Android-only examples, | ||
| but fundamental guidance and navigation principles are the same for Multiplatform: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Sometimes this documentation uses Android-only examples, | |
| but fundamental guidance and navigation principles are the same for Multiplatform: | |
| While some of the documentation uses Android-specific examples, | |
| the core concepts and navigation principles remain consistent across all platforms: |
No description provided.